﻿@model Zatify.WebUI.Models.UserProfileBusinessesFavoritesViewModel
@{
    ViewBag.Title = "Edit Favorites";
    ViewBag.ContentTitle = "Edit Favorites";
    Layout = "~/Views/Shared/_ContentLayoutWithPaging.cshtml";
}
@section Scripts
{
    <script type="text/javascript">

        var businessIds = [];

        function CancelBusinessId(businessId) {

            $("#btnMinus_" + businessId).hide();
            $("#btnCross_" + businessId).show();

            businessIds = jQuery.grep(businessIds, function (value) {
                return value != businessId;
            });

            $("#businessesIds").val(businessIds.join(","));
        }

        function RemoveBusinessId(businessId) {

            $("#btnCross_" + businessId).hide();
            $("#btnMinus_" + businessId).show();

            businessIds.push(businessId);

            $("#businessesIds").val(businessIds.join(","));
        }

        $(document).ready(function () {

            $("#btnDeleteFavorites").click(function () {

                if (businessIds && businessIds.length > 0) {
                    if (confirm("Are you sure to delete selected favorite ?")) {
                        $("#formRemoveFavorites").submit();
                    }
                    else {
                        return;
                    }
                }
            });
        });

    </script>
}
@section ContentTitleButton
{
    @using (Html.BeginForm("FavoritesDelete", "UserProfile", FormMethod.Post, new { id = "formRemoveFavorites", style = "display: inline;" }))
    {
        @Html.Hidden("businessesIds")
        <a href="#" id="btnDeleteFavorites" class="red_btn" style="float: right;">Delete</a>
    }
}
<div class="deal_display">
    <ul>
        @foreach (var business in Model.FavoriteBusinesses)
        {
            <li><a href="#">
                <div style="width: 298px; height: 180px; text-align: center; background:url('@Url.Action("GetBusinessPhoto", "UserProfile", new { businessId = business.BusinessId, w = 298, h = 170 })') no-repeat scroll center center transparent">
                    @*<img alt="" src="@Url.Action("GetBusinessPhoto", "UserProfile", new { businessId = business.BusinessId, w = 298, h = 170 })" />*@
                </div>
                <div class="deal_thumb_content">
                    <h4>
                        1. @business.BusinessName</h4>
                    <div class="rating_price">
                        @InlineHelpers.FiveStarsRatingReadonly(business.Rating)
                        <span class="rating_text">
                            @business.ReviewsCount Reviews</span>
                        <div class="thumb_price">
                            $$</div>
                    </div>
                    <p class="gold">
                        @if (!String.IsNullOrEmpty(business.StreetAddress1))
                        {
                            @InlineHelpers.TrimText(business.StreetAddress1, 35)
                        }
                        else
                        {
                            <text>&nbsp;</text> 
                        }</p>
                    <p class="gray">
                        @if (business.Distance.HasValue)
                        { 
                            @business.Distance.Value.ToString("0.00")<text> mi</text>
                        }
                        else
                        {
                            <text>N/A</text>
                        }
                    </p>
                    <p class="gray">
                        @if (business.Categories != null && business.Categories.Count() > 0)
                        {
                            @InlineHelpers.TrimText(InlineHelpers.BusinessCategories(business.Categories).ToString(), 35)
                        }
                        else
                        {
                            <text>&nbsp;</text> 
                        }
                    </p>
                </div>
            </a>
                <div class="deal_edit_btn">
                    <a id="btnCross_@(business.BusinessId)" href="#" class="cross_btn" onclick="RemoveBusinessId(@business.BusinessId)">
                        cross button</a> <a id="btnMinus_@(business.BusinessId)" href="#" class="minus_btn" onclick="CancelBusinessId(@business.BusinessId)">
                            cross button</a>
                </div>
            </li>
        }
    </ul>
</div>
@section Paging
{
    @Html.Pager(Model.PagingInfo, x => Url.Action("FavoritesEdit", new { page = x }), 3)
}
